package com.hykj.coca.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 *file: CustomWebMvcConfigurerAdapter.java
 * Created by jiaobuchong on 12/23/15.
 */
@Configuration   //标注此文件为一个配置项，spring boot才会扫描到该配置。该注解类似于之前使用xml进行配置
public class CustomWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {

    @Autowired
    private WebInterceptor securityInterceptor;

    @Autowired
    private UserInterceptor userInterceptor;

    @Autowired
    private MobileApiInterceptor mobileApiInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor( userInterceptor).addPathPatterns("/**");  //对来自/user/** 这个链接来的请求进行拦截

        registry.addInterceptor(securityInterceptor).addPathPatterns("/admin/**");//配置登录拦截器拦截路径

        registry.addInterceptor(mobileApiInterceptor).addPathPatterns("/api/**");//配置接口用户拦截器拦截
    }
}